package com.xuliugen.ssm.demo.service.impl;

import com.xuliugen.ssm.demo.dto.SecurityUserDTO;
import com.xuliugen.ssm.demo.mapper.SecurityUserMapper;
import com.xuliugen.ssm.demo.service.SecurityUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by xuliugen on 2017/5/2.
 */
@Service
public class SecurityUserServiceImpl implements SecurityUserService {

    @Autowired
    private SecurityUserMapper securityUserMapper;

    @Override
    public SecurityUserDTO getUserById(Integer id) {
        return securityUserMapper.selectByPrimaryKey(id);
    }

    @Override
    public int getUserCountByUserName(String userName) {
        return securityUserMapper.selectCountByUserName(userName);
    }

    @Override
    public int addUser(SecurityUserDTO userDTO) {
        int userId = securityUserMapper.insertSelective(userDTO);
        return userId;
    }

    @Override
    public int updateUser(SecurityUserDTO userDTO) {
        return securityUserMapper.updateByPrimaryKeySelective(userDTO);
    }

    @Override
    public int delete(Integer userId) {
        return securityUserMapper.deleteByPrimaryKey(userId);
    }
}
